<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<div class="row-fluid">
			<div class="col-sm-12">
				<form class="form-horizontal m-t " id="signupForm" method="post"
					enctype="multipart/form-data">
					<input type="hidden" name="id" value="${trainExp.id}" />
					<input type="hidden" name="talentsId" value="${trainExp.talentsId}" />
					<input type="hidden" name="classify" value="${trainExp.school.classify}" />
					<div class="form-group">
						<label class="col-sm-3 control-label">起止时间：</label>
						<div class="col-sm-8 form-inline">
							<input type="text" class="form-control datetime" id="t_startDate" name="startDate" value="${trainExp.startDate }"  style="width: 40%" readonly="readonly" placeholder="请选择起始时间"/> -
							<input type="text" class="form-control datetime" id="t_endDate" name="endDate" value="${trainExp.endDate }"  style="width: 40%" readonly="readonly" placeholder="请选择截止时间"/>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">培训机构：</label>
						<div class="col-sm-8">
							<input type="text"  class="form-control company" id="t_schoolName" name="schoolName" value="${trainExp.schoolName }"/>
							<input type="hidden"  class="form-control" id="t_schoolId" name="schoolId" value="${trainExp.schoolId }"/>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">培训课程：</label>
						<div class="col-sm-8">
							<input type="text" class="form-control" id="e_course" name="course" value="${trainExp.course }"  />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">获得证书：</label>
						<div class="col-sm-8">
							<input type="text" class="form-control" id="t_grade" name="grade" value="${trainExp.grade }"  />
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-12" style="border: 1px solid #e5e6e7;">
						</div>
					</div>
					<div class="form-group" style="text-align: center;">
						<div class="col-sm-12">
							<button class="btn btn-primary" type="button" id="sub">提交</button>
							<button class="btn btn-primary" type="button"
								onclick="top.Dialog.close();">取消</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	 $(function () {
		 $("#t_schoolName").autosuggest({
	            url: '<%=contextPath%>/school/getJsonSchool?type=2',
	                minLength: 1,
	                maxNum: 4,
	                align: 'center',
	                method: 'post',
	                highlight: true,
	                immediate: true,
	                queryParamName: 'name',
	                nextStep: function (ele) {
	                    var tid = ele.data('id'); 
	                    $("#t_schoolId").val(tid);
	                },
	                split: ' ',
	                open: function(){
	                    //console.log("start open");
	                },
	                close: function(){
	                    //console.log("start close");
	                }
	            });
		 $('.datetime').datetimepicker({
			    format: 'yyyy-mm',
		        autoclose: true,
		        todayBtn: true,
		        startView: 'year',
		        minView:'year',
		        maxView:'decade',
		        language:  'zh-CN',
	    	    autoclose: 1//选择后自动关闭
		  });
		 //$("#t_startDate").datetimepicker("update",'2002-01-01');//赋值
		 $('#t_startDate1').datetimepicker({
	    	 format: 'yyyy-mm',
		        autoclose: true,
		        todayBtn: true,
		        startView: 'year',
		        minView:'year',
		        maxView:'decade',
		        language:  'zh-CN',
	    	    autoclose: 1//选择后自动关闭
	  }).on('hide', function(event) {
		  var year = event.date.getFullYear();//获取年
		  var newyear = year+3;
		  $("#t_endDate").datetimepicker("update",newyear+'-01');//赋值
		});
        $("#sub").click(function () {
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/edu/editSingle',
                data:{'num':2},
				type : 'post',
				dataType : "json",
				beforeSend: function () {
			        // 禁用按钮防止重复提交
					$("#sub").attr("disabled","disabled");
					swal("信息已经提交，请等待后台处理~！");
			    },
				success : function(data) {
					if (data.code == 200) {
						swal({
							title : data.message,
							type : "success",
							showCancelButton : false,
							confirmButtonText : "确定",
							animation : "slide-from-bottom",
							text: "2秒后自动关闭。", 
	      	    			timer: 2000, 
							closeOnConfirm : true
						}, function() {
							top.Dialog.close();
						});
					} else {
						swal("错误", data.message, "error");
					}  
				},    
				complete: function () {
			        $("#sub").removeAttr("disabled");
			    },
			    error: function (data) {
			    	swal("错误", data.message, "error");
			    }
			});
		});
	});
	</script>
</body>
</html>